﻿using _51_AOP.Utility.Filter;
using Microsoft.AspNetCore.Mvc;

namespace _51_AOP.Controllers
{
    public class EceptionController : Controller
    {
        /// <summary>
        /// action出现没有处理的异常
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [TypeFilter(typeof(CustomExceptionFilterAttribute))]
        public IActionResult Index()
        {
            throw new Exception(" action出现没有处理的异常");
        }
        /// <summary>
        /// action出现已经处理的异常
        /// </summary>
        /// <returns></returns>

        [TypeFilter(typeof(CustomExceptionFilterAttribute))]
        public IActionResult index1()
        {
            try
            {
                throw new Exception(" action出现已经处理的异常");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
        /// <summary>
        /// service层异常
        /// </summary>
        /// <returns></returns>
        [TypeFilter(typeof(CustomExceptionFilterAttribute))]
        public IActionResult index2()
        {
            new _51_AOP_DAL.Class1().show();
            return View();
        }

        [TypeFilter(typeof(CustomExceptionFilterAttribute))]
        [CustomResourceFilter]
        /// <summary>
        /// View绑定的异常
        /// </summary>
        /// <returns></returns>
        public IActionResult index3()
        {
            return View();
        }
    }
}
